﻿
using NetworkPower.DataModel.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace NetworkPower.Management
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private NetworkPowerContext context;

        public MainWindow()
        {
            InitializeComponent();
            //context = new NetworkPowerContext();
            //context.Database.CreateIfNotExists();
        }



        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (txtUsername.Text.Length != 0 & txtPassword.Text.Length != 0)
            {

                //var count = context.Users.Count(o => o.UserName == txtUsername.Text);

                //if (count == 1)
                //{
                //    MessageBox.Show("用户已存在.");
                //    txtPassword.Clear();
                //    txtUsername.Clear();
                //    txtUsername.Focus();
                //    return;
                //}

                //context.Users.Add(new User { UserName = txtUsername.Text, Password = txtPassword.Text, CreateDate = DateTime.Now });
                //context.SaveChanges();
                //MessageBox.Show("请点击确认输入下一个用户.");
                //txtPassword.Clear();
                //txtUsername.Clear();
                //txtUsername.Focus();
            }
            else
            {
                MessageBox.Show("请补全用户名和密码.");
            }

        }
    }
}
